package com.javabasic.java8;

import java.io.UnsupportedEncodingException;

/**
 * @author: xiongmin
 * @since create by 2022/5/16 19:39
 */
public class CharacterTest {

    /**
     * 深入编码原理
     * @param args
     * @throws UnsupportedEncodingException
     */
    public static void main(String[] args) throws UnsupportedEncodingException {
        String chars = "NIHAO,一小熊敏😀";

        /**
         * 字节数
         */
        System.out.println(chars.getBytes().length);
        System.err.println("GBK==" + chars.getBytes("GBK").length);
        System.err.println("UTF-8==" + chars.getBytes("UTF-8").length);
        System.err.println("GB2312==" + chars.getBytes("GB2312").length);
        System.err.println("ISO-8859-1==" + chars.getBytes("ISO-8859-1").length);

        /**
         *
         */
        System.out.println(chars.length());

        String encoding = System.getProperty("file.encoding");
        System.out.println("Default System Encoding:" + encoding);

    }
}
